package com.rich.dmr.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.LinearLayout;

import com.rich.dmr.R;
import com.rich.dmr.ui.view.SimpleToolbar;
import com.rich.dmr.utils.Constant;

public class DmrDigitalModeActivity extends AppCompatActivity implements View.OnClickListener {
    private String TAG = "rich---DmrDigitalModeActivity";
    private Intent intent = new Intent();
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dmr_digital_mode);

        SimpleToolbar simpleToolbar = findViewById(R.id.settings_tools_bar);
        simpleToolbar.setLeftTitleClickListener(this);
        simpleToolbar.setLeftTitleDrawable(R.mipmap.nav_back_icon);
        simpleToolbar.setMainTitle(getString(R.string.tools_digital_mode));

        LinearLayout receiverFrequency = findViewById(R.id.digital_receiver_frequency);
        receiverFrequency.setOnClickListener(this);

        LinearLayout transmitFrequency = findViewById(R.id.digital_transmit_frequency);
        transmitFrequency.setOnClickListener(this);

        LinearLayout localId = findViewById(R.id.digital_local_id);
        localId.setOnClickListener(this);

        LinearLayout groupList = findViewById(R.id.digital_group_list);
        groupList.setOnClickListener(this);

        LinearLayout transmitContact = findViewById(R.id.digital_transmit_contact);
        transmitContact.setOnClickListener(this);

        LinearLayout callType = findViewById(R.id.digital_call_type);
        callType.setOnClickListener(this);

        LinearLayout power = findViewById(R.id.digital_power);
        power.setOnClickListener(this);

        LinearLayout volume = findViewById(R.id.digital_volume);
        volume.setOnClickListener(this);

        LinearLayout mic = findViewById(R.id.digital_mic);
        mic.setOnClickListener(this);

        LinearLayout rxFrequency = findViewById(R.id.digital_rx_frequency);
        rxFrequency.setOnClickListener(this);
        LinearLayout txFrequency = findViewById(R.id.digital_tx_frequency);
        txFrequency.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.txt_left_title:
                finish();
                break;
            case R.id.digital_receiver_frequency:
                startInnerActivity(R.string.digital_receiver_frequency);
                break;
            case R.id.digital_transmit_frequency:
                startInnerActivity(R.string.digital_transmit_frequency);
                break;
            case R.id.digital_rx_frequency:
                Intent rxIntent = new Intent();
                rxIntent.setClass(this,RxFrequencyActivity.class);
                startActivity(rxIntent);
                break;
            case R.id.digital_tx_frequency:
                Intent txIntent = new Intent();
                txIntent.setClass(this,TxFrequencyActivity.class);
                startActivity(txIntent);
                break;
            case R.id.digital_local_id:
                startInnerActivity(R.string.digital_local_id);
                break;
            case R.id.digital_group_list:
                startInnerActivity(R.string.digital_group_list);
                break;
            case R.id.digital_transmit_contact:
                startInnerActivity(R.string.digital_transmit_contact);
                break;
            case R.id.digital_call_type:
                startInnerActivity(R.string.digital_call_type);
                break;
            case R.id.digital_power:
                startInnerActivity(R.string.digital_power);
                break;
            case R.id.digital_volume:
                startInnerActivity(R.string.digital_volume);
                break;
            case R.id.digital_mic:
                startInnerActivity(R.string.digital_mic);
                break;
            default:
                break;

        }
    }

   public void startInnerActivity(int id){
       intent.setClass(this,DigitalParamActivity.class);
       intent.putExtra(Constant.key,id);
       startActivity(intent);
   }
}
